import { getCouponClassify } from '@/services/marketCenter/YHQ'

const YhqModel = {
  namespace: 'YHQ',
  state: {
    couponClassify: [],
    // 优惠券状态
    couponStatus: [
      {
          label: '未开始',
          value: '0'
      },
      {
          label: '进行中',
          value: '1'
      },
      {
          label: '已结束',
          value: '2'
      },
    ],
    // 优惠券类型
    couponTypes: [
      {
          label: '满减券',
          value: '1'
      },
      {
          label: '折扣券',
          value: '2'
      },
      {
          label: '礼品券',
          value: '3'
      },
    ],
    // 优惠券发放类型
    couponSendTypes: [
      {
        label: '全部',
        value: '0'
      },
      {
        label: '手工发送',
        value: '1'
      },
      {
          label: '自助领取',
          value: '2'
      },
      {
          label: '活动赠送',
          value: '3'
      },
    ]
  },
  effects: {
    *getCouponClassify(_, { call, put, select }) {
      const data = yield call(getCouponClassify);
      yield put({
        type: 'saveData',
        payload: {
          couponClassify: data.data
        },
      });
    },
  },
  reducers: {
    saveData(state, { payload }) {
      return {
        ...state,
        ...payload
      }
    },
  },
  subscriptions: {
    setup({ history }) {
      // Subscribe history(url) change, trigger `load` action if pathname is `/`
    },
  }
}

export default YhqModel
